package com.bbx.taxi.client.Util;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderDetail;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderList;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderList2;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OrderInfo;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.UnprocessedList.UnprocessedList;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.UnprocessedList.UnprocessedList2;
import com.bbx.api.sdk.net.base.JsonBuild;

/** 
 * @Path com.bbx.taxi.client.Util.UnprocessedListConvert.java
 * @Author 严旭文
 * @Date 2016-1-28 上午11:09:41
 * @Company 蓝海（福建）信息技术有限公司
 * @Description
 */
public class UnprocessedListConvert {
	/**
     * OfficialOrderList2转换为OfficialOrderList
     */
	public static UnprocessedList onConvert(UnprocessedList2 mUnprocessedList2) {
		UnprocessedList mUnprocessedList = null;
		String order_detail = mUnprocessedList2.getOrderDetail();
		String other_info = mUnprocessedList2.getOrderInfo();
		 try {
				JSONObject json_detail= new JSONObject(order_detail);
				order_detail=json_detail.toString();
				mUnprocessedList2.setOrderDetail(null);
				mUnprocessedList2.setOrderInfo(null);
				
				String JsonString = new JsonBuild().setModel(mUnprocessedList2).getJsonString();
				
				mUnprocessedList = (UnprocessedList) new JsonBuild().getData(UnprocessedList.class,
						JsonString);
				OfficialOrderDetail mOfficialOrderDetail = (OfficialOrderDetail) new JsonBuild().getData(OfficialOrderDetail.class,
							order_detail);
				OrderInfo mOrderInfo = (OrderInfo) new JsonBuild().getData(OfficialOrderDetail.class,
						other_info);
				mUnprocessedList.setOrderDetail(mOfficialOrderDetail);
				mUnprocessedList.setOrderInfo(mOrderInfo);
			} catch (JSONException e) {}
		return mUnprocessedList;

	}
	public static ArrayList<UnprocessedList> onConvert(ArrayList<UnprocessedList2> list_unprocess2){
		ArrayList<UnprocessedList> list=new ArrayList<UnprocessedList>();
		for(int i=0;i<list_unprocess2.size();i++){
			UnprocessedList mUnprocessedList = null;
			String order_detail = list_unprocess2.get(i).getOrderDetail();
			String other_info = list_unprocess2.get(i).getOrderInfo();
			 try {
					JSONObject json_detail= new JSONObject(order_detail);
					order_detail=json_detail.toString();
					list_unprocess2.get(i).setOrderDetail(null);
					list_unprocess2.get(i).setOrderInfo(null);
					
					String JsonString = new JsonBuild().setModel(list_unprocess2.get(i)).getJsonString();
					
					mUnprocessedList = (UnprocessedList) new JsonBuild().getData(UnprocessedList.class,
							JsonString);
					OfficialOrderDetail mOfficialOrderDetail = (OfficialOrderDetail) new JsonBuild().getData(OfficialOrderDetail.class,
								order_detail);
					OrderInfo mOrderInfo = (OrderInfo) new JsonBuild().getData(OrderInfo.class,
							other_info);
					mUnprocessedList.setOrderDetail(mOfficialOrderDetail);
					mUnprocessedList.setOrderInfo(mOrderInfo);
					list.add(mUnprocessedList);
				} catch (JSONException e) {}
		}
		return list;
		
	}
}
